package etcMycat.controller;

import etcMycat.dto.Result;
import etcMycat.entity.ETCToSZ;
import etcMycat.service.CarTypeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/car")
public class CarTypeContoller {
    @Resource
    private CarTypeService carTypeService;

    @GetMapping("/sum")
    public Result CarList(){
        log.info("车辆总数");
        int count = carTypeService.count();
        return Result.success(count);
    }

    @GetMapping("/from")
    public Result from(){
        log.info("省份来源");
        List<ETCToSZ> from=carTypeService.from();
        return Result.success(from);
    }

    @GetMapping("/cx")
    public Result cx(){
        log.info("车型及其数量分布");
        List<ETCToSZ> cxcount=carTypeService.cxcount();
        return Result.success(cxcount);
    }
}
